//
//  ProgressView.swift
//  SinaWeiBo
//
//  Created by ZKJ on 2017/11/21.
//  Copyright © 2017年 ZKJ. All rights reserved.
//

import UIKit

class ProgressView: UIView {
    
    // MARK:- 定义属性
    var progress : CGFloat = 0 {
        didSet {
            setNeedsDisplay()
        }
    }
    
    // MARK:- 重写drawRect方法
    override func draw(_ rect: CGRect) {
        super.draw(rect)
        //获取参数
        let center = CGPoint(x: rect.size.width * 0.5, y: rect.size.height * 0.5)
        let radius = rect.size.width * 0.5 - 5
        let startAngle = -CGFloat(Double.pi / 2)
        let endAngle = CGFloat(2 * Double.pi) + startAngle
        
        let path = UIBezierPath(arcCenter: center, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: true)
        path.addLine(to: center)
        path.close()
        UIColor(white: 0.6, alpha: 0.6).setFill()
        path.fill()
    }
}

